package org.sample.service.impl;

import java.util.List;

import org.sample.commons.bean.BeanUtils;
import org.sample.dao.ConfigDao;
import org.sample.entity.Config;
import org.sample.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ConfigServiceImpl implements ConfigService {

    @Autowired
    private ConfigDao dao;

    @Override
    public List<Config> getIdNameList() {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public void logicalDelete(Integer id) {
        Config entity = dao.getOne(id);
        entity.setDeleted(true);
        dao.save(entity);
    }

    @Override
    public Config saveNotNull(Config entity) {
        if (entity.getId() == null) {
            return dao.save(entity);
        }
        Config oldEntity = dao.getOne(entity.getId());
        BeanUtils.copyBeanNotNull(entity, oldEntity);
        return dao.save(oldEntity);
    }
}